package com.fyz.aaronfjava.common.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author：fanyaozhou
 * @Date：2023/12/4 11:24
 * @description bean生命周期回调函数
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    /**
     * bean初始化方法之前
     * @param bean the new bean instance
     * @param beanName the name of the bean
     * @return 将传入的bean return出去
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        // TODO
        return bean;
    }

    /**
     * bean初始化方法之后
     * @param bean the new bean instance
     * @param beanName the name of the bean
     * @return 将传入的bean return出去
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        // TODO
        return bean;
    }

}